﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;
using System.IO;
using System.Diagnostics;

namespace RestaurantBooker.Web.Data
{
    public sealed partial class Room 
    {
        BitmapImage _roomBitmap = null;

        /// <summary>
        /// Return bitmap image from their array data - ONLY ONCE!!
        /// </summary>
        public BitmapImage RoomBitmap
        {
            get {
                if (_room_background == null || _room_background.Length == 0)
                    return null;

                //TODO: if image does not exist - reyurn special image with EMTY text? for example.
                if (_roomBitmap == null)
                { //  create image
                    Debug.WriteLine("RoomBitmap property getter called.");
                    _roomBitmap = new BitmapImage();
                    using (var ms = new MemoryStream(_room_background))
                    {
                        _roomBitmap.SetSource(ms);                        
                    }                    
                }
                return _roomBitmap;
            }
        }
    }
}
